home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
clipper
/
rcmplb30.zip
/
RCMPDEMO.PRG
< prev
next >
Wrap
Text File
|
1994-02-20
|
16KB
|
462 lines
*--------------------------------------------------------------------------
* CA-CLIPPER 5.xx VERSION
*--------------------------------------------------------------------------
* RCmpDemo.PRG - Program to demonstrate the use of the functions
* in the CA-Clipper Library, RCmpLib v3.0
*
* Used functions :
*
* R_CmpFile () - Compress one or more files into one archive
* R_DCmpFile () - Extract one or more files from an archive
* R_CmpList () - Retrieves info about files in a RCmpLib archive
* R_FSize () - Determine the size of a file
* R_LastErr () - Determine last error
* R_CmpStr () - Compress a string
* R_DCmpStr () - Decompress a string
*
* Compile : CLIPPER RCMPDEMO /N
*
* Link : RTLINK file RCMPDEMO lib RCMPLIB - or -
* BLINKER file RCMPDEMO lib RCMPLIB - or -
* EXOSPACE file RCMPDEMO lib RCMPLIB EXO PAC INT10
*
* Syntax : RCMPDEMO
*--------------------------------------------------------------------------
* Date : 20/02/94
*--------------------------------------------------------------------------
* Author : Rolf van Gelder
* Binnenwiertzstraat 27
* 5615 HG EINDHOVEN
* THE NETHERLANDS
*
* E-Mail : Internet : RCROLF@urc.tue.nl
* BitNet : RCROLF@heitue5
* CompuServe : >INTERNET:rcrolf@urc.tue.nl
*--------------------------------------------------------------------------
* (c) 1994 Rolf van Gelder, All rights reserved
*--------------------------------------------------------------------------
*--------------------------------------------------------------------------
* Standard Clipper HEADER files
*--------------------------------------------------------------------------
#include "Directry.CH"
#include "Set.CH"
*--------------------------------------------------------------------------
* RCMPLIB header file
*--------------------------------------------------------------------------
#include "RCmpLib.CH"
*-- Initialize the array with error messages (from RCmpLib.CH)
STATIC aErrTxt := CP_ERRMSG
*--------------------------------------------------------------------------
* STATIC CODEBLOCKS
*--------------------------------------------------------------------------
*-- Display "Hit any key" message & wait for a key
STATIC bHitKey := { || DevPos (MaxRow(), 32), DevOut ( 'Hit any key ....' ),;
InKey ( 0 ) }
*-- Display headerline (with clear screen)
STATIC bHeader := { || Scroll (), DevPos ( 0, 0 ), ;
DevOut ('RCmpDemo: Demo program for RCmpLib v3.0 - '+;
'20/02/94 (c) 1994 Rolf van Gelder' ), ;
DevPos ( 1, 0 ), ;
DevOut ( Replicate ( '─', 80 ) ) }
*--------------------------------------------------------------------------
*
* Main function : RCmpDemo
*
*--------------------------------------------------------------------------
FUNCTION RCmpDemo
*-- Main menu
LOCAL aMenu := { ;
'Compress files into an archive - R_CmpFile()' , ;
'Show file-info from an archive file - R_CmpList()', ;
'Extract files from an archive - R_DCmpFile()', ;
'String compression/decompression - R_CmpStr(),R_DCmpStr()', ;
'End of Demo' }
LOCAL nChoice := 1 && Menu choice
LOCAL nRetCode && Return code
LOCAL cOldCol && Old color
LOCAL aCmpList && Array with file-info
LOCAL nTotOrgSize && Counter
LOCAL nTotCmpSize && Counter
LOCAL nFiles && Counter
LOCAL nHandle && File handle
LOCAL cString && String buffer
LOCAL nOrgSize && Original string size
LOCAL nCmpSize && Compressed string size
SetColor ( 'W+/B' )
*-- Disable scoreboard
Set ( _SET_SCOREBOARD, .f. )
*--------------------------------------------------------------------------
* M A I N P R O G R A M L O O P
*--------------------------------------------------------------------------
DO WHILE .t.
*-- Display header lines
Eval ( bHeader )
*-- Do some advertisement ...
DevPos ( 2,21 )
DevOut ( 'THE COMPRESSION LIBRARY FOR CA-CLIPPER' )
DevPos ( 4, 11 )
DevOut ( ' ▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄ ▄ ▄▄ ▄ ' )
DevPos ( 5, 11 )
DevOut ( '▒▒▒▒▒▒▒█ ▒▒▒▒▒▒▒▀ ▒█ ▒▒▀ ▒█ ' )
DevPos ( 6, 11 )
DevOut ( '▒█▄▄▄▄▒█ ▒█ ▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄ ▒█ ▄▄ ▒█▄▄▄▄▄▄' )
DevPos ( 7, 11 )
DevOut ( '▒▒▒▒▒▒▒▀ ▒█ ▒▒▒▒▒▒▒█ ▒▒▒▒▒▒▒█ ▒█ ▒▒█ ▒▒▒▒▒▒▒█' )
DevPos ( 8, 11 )
DevOut ( '▒█ ▒▀▄ ▒█▄▄▄▄▄▄ ▒▒█▒█▒▒█ ▒█▄▄▄▄▒█ ▒█▄▄▄▄▄▄ ▒▒█ ▒█▄▄▄▄▒█' )
DevPos ( 9, 11 )
DevOut ( '▒▀ ▒▀ ▒▒▒▒▒▒▒▀ ▒▒▀▒▀▒▒▀ ▒▒▒▒▒▒▒▀ ▒▒▒▒▒▒▒▀ ▒▒▀ ▒▒▒▒▒▒▒▀' )
DevPos ( 10, 11 )
DevOut ( ' ▒█ ' )
DevPos ( 11, 11 )
DevOut ( ' (c) 1994 Rolf van Gelder ▒▀ Eindhoven, The Netherlands ' )
*-- Draw double box for main menu
DispBox ( 13, 8, 19, 71, 2 )
*-- Display main menu
nChoice := AChoice ( 14, 10, 18, 69, aMenu, , , nChoice )
IF LastKey () = 27 .or. nChoice = Len ( aMenu )
*-- <Esc> or 'End of Demo'
EXIT
ENDIF
*-- Display header lines
Eval ( bHeader )
DO CASE
CASE nChoice = 1
*-- COMPRESS FILES INTO AN ARCHIVE
CenterMsg ( 3, 'COMPRESS FILES INTO AN ARCHIVE - R_CmpFile()' )
cOldCol := SetColor ( 'W+/BG' )
DispBox ( 5, 13, 8, 64 )
DevPos ( 6, 14 )
DevOut ( ' The files RCMPLIB.*, *.PRG and DUTCH.REG will be ' )
DevPos ( 7, 14 )
DevOut ( ' compressed into an archive called ARCHIVE.RCP. ' )
SetColor ( cOldCol )
*-- Hit any key ....
Eval ( bHitKey )
Scroll ( 5, 0 )
*-- Draw box for progression bar
cOldCol := SetColor ( 'W+/R' )
Scroll ( 6, 23, 8, 56 )
DispBox ( 6, 23, 8, 56 )
SetColor ( cOldCol )
DevPos ( 9,25 )
DevOut ( 'Compressing: ' )
*--------------------------------------------------------------------
* Files to compress : RCmpLib.*, *.PRG and Dutch.REG
* Archive file : Archive.RCP
* Keep originals : lMove = .F.
* Progression bar : Length = 30, (Row,Col) = (7,25)
* : Character = Chr (177), Color = Yellow on Red
* Password : none (nil)
* Interruptable : lEscape = .T.
* CodeBlock : Function DispName ( Fname, row, col )
*--------------------------------------------------------------------
nRetCode := R_CmpFile ( { 'RCmpLib.*', '*.PRG', 'Dutch.REG' }, ;
'Archive.RCP', .F., 30, 7, 25, Chr ( 177 ), 'GR+/R', nil, .T., ;
{ |x| DispName ( x, 9, 38 ) } )
* nRetCode := R_CmpFile ( { 'RCmpLib.*', '*.PRG', 'Dutch.REG' }, ;
* 'Archive.RCP', .F., 10, 7, 25, Chr ( 177 ), 'GR+/R', nil, .T., ;
* { |x| DispName ( x, 9, 38 ) } )
*-- Clear box
Scroll ( 6, 0 )
IF nRetCode != CP_OKAY
*-- Error detected : display error message
Alert ( 'Error compressing: ' + aErrTxt [ nRetCode ] )
ELSE
*-- No errors detected !
Alert ( 'Archive ARCHIVE.RCP created.' )
ENDIF
CASE nChoice = 2
*-- SHOW FILE-INFO FROM AN ARCHIVE FILE
CenterMsg ( 3, 'SHOW FILE-INFO FROM AN ARCHIVE FILE - R_CmpList()' )
cOldCol := SetColor ( 'W+/BG' )
DispBox ( 5, 17, 8, 60 )
DevPos ( 6, 18 )
DevOut ( ' File information for the files in the ' )
DevPos ( 7, 18 )
DevOut ( ' archive file ARCHIVE.RCP will be listed. ' )
SetColor ( cOldCol )
*-- Hit any key ....
Eval ( bHitKey )